package edu.whu.notepal.dto;

import lombok.Data;

/**
 *
 * @author 陈磊
 * @param <T>
 */
@Data
public class Result<T> {

    /**
     * 编码：1成功，0和其它数字为失败
     */
    private Integer code;

    /**
     * 错误信息
     */
    private String msg;

    /**
     * 数据
     */
    private T data;


    public static <T> Result<T> success(T data) {
        Result r = new Result<T>();
        r.data = data;
        r.code = 1;
        return r;
    }


    public static Result fail(String msg) {
        Result r = new Result();
        r.msg = msg;
        r.code = 0;
        return r;
    }

}